home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / SAS-C / sc655pch / source / _tzset.c
Encoding:
C/C++ Source or Header  |  1995-01-09  |  1.1 KB  |  73 lines

  1. /***
  2. *
  3. *          Copyright © 1994  Lattice, Inc.
  4. *
  5. * name             __tzset -- set time zone parameters
  6. *
  7. * synopsis         __tzset();
  8. *
  9. * description      This function sets the time zone variables __daylight,
  10. *                  __timezone, and __tzname from the information in the
  11. *                  TZ environment variable.
  12. *
  13. ***/
  14.  
  15. #include <time.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18.  
  19.  
  20.  
  21. void __tzset()
  22. {
  23.     char   *p;
  24.     int    x;
  25.  
  26.  
  27. #ifdef LESS_GETENV
  28.  
  29.     p = _TZ;
  30.     if (p == NULL)
  31.        _TZ = p = __getenv("TZ");
  32.  
  33. #else
  34.  
  35.     char *q;
  36.     q = p = __getenv("TZ");
  37.  
  38.     if (p == NULL)
  39.         p = _TZ;
  40.  
  41. #endif
  42.  
  43.     if (p == NULL)
  44.         p = "CST6";
  45.  
  46.     __tzstn[0] = p[0];
  47.     __tzstn[1] = p[1]; 
  48.     __tzstn[2] = p[2];
  49.     __tzstn[3] = '\0';
  50.  
  51.     __tzname[0] = __tzstn;
  52.  
  53.     p += __stcd_i(&p[3], &x) + 3;
  54.     __timezone = x * 3600;
  55.  
  56.     if (*p != '\0') {
  57.         __tzdtn[0] = p[0];
  58.         __tzdtn[1] = p[1];
  59.         __tzdtn[2] = p[2];
  60.         __tzdtn[3] = '\0';
  61.         __daylight = 1;
  62.     } else {
  63.         __tzdtn[0] = '\0';
  64.         __daylight = 0;
  65.     }
  66.  
  67.     __tzname[1] = __tzdtn;
  68.     
  69. #ifndef LESS_GETENV
  70.     if (q) free(q);
  71. #endif
  72. }
  73.